<template>
  <div class="dashboard-container-content-right-part3">
    <PartTitle title="虎鲸网络安全实验室" />
    <div
      class="dashboard-container-content-right-part3-more"
      @click="handleSwitch"
    >
      切换
    </div>
    <div class="dashboard-container-content-right-part3-content">
      <div class="swiper-page">
        <div class="container-list">
          <swiper :options="swiperOptions" ref="mySwiper">
            <swiper-slide v-for="(item, index) in slideList" :key="index">
              <div class="container">
                <img
                  :src="item.url"
                  alt="实验室原理及实物"
                  style="width: 100%; height: 280px"
                />
              </div>
            </swiper-slide>
          </swiper>
          <div class="swiper-pagination1" slot="pagination"></div>
          <div class="swiper-button-next1" slot="button-next"></div>
          <div class="swiper-button-prev1" slot="button-prev"></div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
  import {swiper, swiperSlide} from "vue-awesome-swiper";
  import "swiper/css/swiper.css";
  import PartTitle from "./partTitle.vue";

  export default {
  name: "ContentRightPart3",
  components: {
    swiper,
    swiperSlide,
    PartTitle,
  },
  data() {
    return {
      swiperOptions: {
        loop: true, //无限循环
        autoplay: {
          //自动切换
          delay: 5000,
          stopOnLastSlide: false, //切换到最后一个slide时停止自动切换
          disableOnInteraction: false, //用户操作swiper之后，是否禁止自动切换。默认为true
        },
        // 显示分页
        pagination: {
          el: ".swiper-pagination1", //若改变分页样式，需改变样式名字，默认为.swiper-pagination
          type: "bullets",
          clickable: true, //允许分页点击跳转
        },
        // 设置点击箭头
        navigation: {
          nextEl: ".swiper-button-next1", //若改变右箭头样式，需改变名字，默认为.swiper-button-next
          prevEl: ".swiper-button-prev1", //若改变左箭头样式，需改变名字，默认为.swiper-button-prev
        },
      },
      //数据列表
      slideList: [
        {
          url: require("@/assets/images/hujing1.png"),
        },
        {
          url: require("@/assets/images/hujing2.png"),
        },
        {
          url: require("@/assets/images/hujing3.png"),
        },
        {
          url: require("@/assets/images/hujing4.png"),
        },
      ],
    };
  },
  methods: {
    handleSwitch() {
      if (this.$refs.mySwiper && this.$refs.mySwiper.swiper) {
        if (this.$refs.mySwiper.swiper.autoplay.running) {
          this.$refs.mySwiper.swiper.autoplay.stop();
          this.$message({
            message: "已停止自动轮播",
            type: "success",
          });
        } else {
          this.$refs.mySwiper.swiper.autoplay.start();
          this.$message({
            message: "已开启自动轮播",
            type: "success",
          });
        }
      }
    },
  },
};
</script>
<style lang="scss" scoped>
.dashboard-container-content-right-part3 {
  width: 100%;
  height: 380px;
  border-radius: 14px;
  background: linear-gradient(180deg, #314175 0%, #0e1428 100%);
  box-shadow: 0px 20px 101px 0px #0303033f;
  padding: 22px;
  position: relative;
  &-more {
    position: absolute;
    right: 22px;
    top: 12px;
    width: 100px;
    height: 32px;
    border-radius: 8px;
    background: #486eb5;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #ffffff;
    font-family: Lato;
    font-weight: SemiBold;
    font-size: 13px;
    float: right;
    cursor: pointer;
    z-index: 99;
  }
  &-content {
    margin-top: 20px;
  }
  .swiper-page {
    //设置轮播图外层基本样式：大小，背景颜色等
    width: 100%;
    box-sizing: border-box;

    .container-list {
      //设置相对定位，用于定位左右箭头
      position: relative;
    }
    //设置轮播图整体样式
    .swiper-container {
      width: 100%;
      height: 270px;
      border-radius: 5px;
    }

    //设置分页样式
    .swiper-pagination1 {
      position: relative;
      text-align: center;
      :deep(.swiper-pagination-bullet) {
        width: 10px;
        height: 10px;
        background: transparent;
        border: 2px solid;
        border-image: linear-gradient(95.91deg, #6ddcff 0%, #7f60f9 100%) 1;
        border-radius: 50%;
        margin: 0 3px;
        &.swiper-pagination-bullet-active {
          background: linear-gradient(95.91deg, #6ddcff 0%, #7f60f9 100%);
          border: none;
          opacity: 1;
        }
      }
    }
    .container {
      .detail {
        color: #fff;
      }
    }
  }
}
</style>
